package xyz.xtt.client.starter.lock;

import static java.util.stream.Collectors.joining;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * CacheConfig.java
 * </p>
 *
 * @author zlhqb
 * @since 2023年2月20日
 */
public interface LockConfig {
	public static final String EMPTY = "";
	String delimiter = ":";
	String prefix = "lock" + delimiter;

	String prefix();

	long ttl();

	TimeUnit timeUnit();

	default String genKey(String... keys) {
		int len = keys.length;
		if (len == 0) {
			return prefix + prefix();
		}
		return Arrays.asList(keys).stream().collect(joining(delimiter, prefix + prefix() + delimiter, EMPTY));
	}
}
